package uvt.map.graph.element;

import java.util.ArrayList;
import java.util.TreeMap;

public class StreetTreeMap {
	
	private TreeMap<String,ArrayList<Segment>> listStreet;
	
	public StreetTreeMap() {
		listStreet = new TreeMap<String,ArrayList<Segment>>();
	}
	
	public void add(String name,Segment seg) {
		if(listStreet.containsKey(name)) {
			listStreet.get(name).add(seg);
		} else {
			ArrayList<Segment> list = new ArrayList<Segment>();
			list.add(seg);
			listStreet.put(name,list);
		}
	}
	
	public Street getStreet(String name) {
		Street street = new Street();
		street.setName(name);
		for(Segment s : listStreet.get(name)) {
			street.addSegment(s);
		}
		return street;
	}

}
